| Conditions | 2 |
| Paths | 1 |
| Total Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | /** |
||
| 21 | export const renameKey = function(object, oldName, newName) { |
||
| 22 | if (typeof object !== 'object') { |
||
| 23 | throw `Cannot rename property of a non-object, ${ typeof object } given`; |
||
| 24 | } |
||
| 25 | |||
| 26 | const newObject = clone(object); |
||
| 27 | Object.defineProperty(newObject, newName, Object.getOwnPropertyDescriptor(newObject, oldName)); |
||
| 28 | delete newObject[oldName]; |
||
| 29 | |||
| 30 | return newObject; |
||
| 31 | }; |
||
| 32 |